﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBMigrator.Core.DbObjects.Data.Select;
using DBMigrator.Core.DbObjects.Data.What;
using DBMigrator.Core.DbObjects.Data.Where;
using Rhino.Mocks;
using Xunit;

namespace DBMigrator.Core.Tests.DbObjects.Data
{
    public class SelectTests
    {
        private readonly IFrom from;
        private readonly IWhere where;
        private readonly IWhat what;

        public SelectTests()
        {
            from = MockRepository.GenerateMock<IFrom>();
            where = MockRepository.GenerateMock<IWhere>();
            what = MockRepository.GenerateMock<IWhat>();
        }

        [Fact]
        public void SqlGenerationTypeShouldReturnISelect()
        {
            Assert.Equal(typeof(ISelect), new Select(from, where, what).SqlGenerationType);
        }

        [Fact]
        public void ConstructorShouldThrowIfWhatIsNull()
        {
            Assert.Throws<ArgumentNullException>(() => new Select(from, where, null));
        }

        [Fact]
        public void ConstructorShouldSetWhat()
        {
            Assert.Equal(what, new Select(from, where, what).What);
        }
    }
}
